Skip to main content

All Questions

1vote
1answer
629views

bash script to redirect the output of 'cut' / 'find' to 'scp' with some transformations applied

I need to redirect the output of cut / find to scp with filename transformations applied in between. Background: I am using clearcase for version control. I have branch feature brached off of /Main. ...
HarshaD's user avatar
1vote
1answer
2kviews

Piping errors to my function causes command to be ignored after 1 failure

Context: I have a Bash Script that copies files function log () { read IN if [ "$IN" == "" ]; then : else echo "$datetime"$'\t'"$IN" | tee -a logfile fi } function ...
Timothy Wong's user avatar
15votes
3answers
2kviews

head eats extra characters

The following shell command was expected to print only odd lines of the input stream: echo -e "aaa\nbbb\nccc\nddd\n" | (while true; do head -n 1; head -n 1 >/dev/null; done) But instead it just ...
anton_rh's user avatar
0votes
1answer
886views

Removing lines and trailing commas from mysqldump

I'm trying to remove constraints from a mysqldump before piping it into another SQL database. Mysqldump generates tables that look something like this with 1 or more constraints: CREATE TABLE `...
Robert Fraser's user avatar
5votes
2answers
2kviews

A better way than `tee | cut | ... | paste`

Trying to do a "lookup" in a pipeline, where the input looks like this: alice 5 bob 7 ... I want to look up codes in the second column in a database and return the corresponding name, and keep on ...
Neil McGuigan's user avatar
1vote
1answer
156views

Why don't the SHA's match?

I am trying to write a script and it uses the SHA of a date but I am getting two different results and for the life of me can't figure out why. echo -n 03112016 | cut -d'.' -f4 | sha256sum | cut -d' '...
leigon's user avatar
0votes
1answer
917views

Trying to Use awk by implementating a condition and implication

I have a file containing 8 columns, One of my tasks is to get the values of Column 3 and if the value of the row is not equal to 123 the 8 coloumns will be printed and hence If column 3 is equal to ...
user146120's user avatar
3votes
2answers
5kviews

Curl url txt file, but grep each url separately from single file

I have a text file with lots of url's in it. I'm using curl -K "$urls" > $output to spit the output to my output file. Now for the output of each separate url there is a term, let's say "mortgage",...
neilH's user avatar
1vote
4answers
2kviews

optimize command with or and pipe to parse the output of ifconfig

I have this command line, but it's doubling the grep and awk ifconfig eth1 2> /dev/null | grep "inet " | awk '{gsub("addr:","",$2); print $2 }' || ifconfig eth0 2> /dev/null | grep "inet " | ...
Quantum's user avatar
2votes
2answers
2kviews

One-liner to sort and uniq two outputs

I'm currently doing this to sort and uniq the output of two different commands: tshark -r sample.pcap -T fields -e eth.src -e ip.src > hello tshark -r sample.pcap -T fields -e eth.dst -e ip.dst &...
Juicy's user avatar
  • 4,095
2votes
3answers
4kviews

Extract two values from the output of a command

I'm using the following command in a script to get synthetic wifi info: echo "$( iw dev wlp1s0 link | grep '^\s*SSID:\s' | sed -r 's/^\s*SSID:\s//' ) $( iw dev wlp1s0 link | grep '...
fonini's user avatar
3votes
1answer
1kviews

Command for killing specific PID provided by previous command

Sometimes I need to kill a process (the reasons why are not important). And I know I can find that process with the following command: lsof -i :8080, being my candidate the last process in the output ...
Dani Sancas's user avatar
14votes
9answers
5kviews

Filter or pipe certain sections of a file

I have an input file with some sections the are demarcated with start and end tags, for example: line A line B @@inline-code-start line X line Y line Z @@inline-code-end line C line D I want to apply ...
James Scriven's user avatar
5votes
4answers
3kviews

How to fill a file with a stream from /dev/urandom with a specified number of lines ?

I am trying to fill a file with a sequence of random 0 and 1s with a user-defined number of lines and number of characters per line. the first step is to get a random stream of 0 and 1s: cat /dev/...
Abdul Al Hazred's user avatar
10votes
4answers
3kviews

Split an input for different command and combine the result

I know how to combine the result of different command paste -t',' <(commanda) <(commandb) I know pipe same input to different command cat myfile | tee >(commanda) >(commandb) Now how to ...
user40129's user avatar

153050per page
close